<template>
  <div class="cartcontrol">
    <div class="iconfont icon-tianjia" @click.stop="addCommodityCount(true)"></div>
    <div class="cart-count" v-if="commodity.count">{{commodity.count}}</div>
    <transition name="count">
      <div class="iconfont icon-shanchu1" v-if="commodity.count" @click.stop="addCommodityCount(false)"></div>
    </transition>
  </div>
</template>

<script>
  export default {
    props:{
      commodity: Object
    },
    mounted(){
      console.log(this.commodity)
    },
    methods:{
      addCommodityCount (isCount){
        this.$store.dispatch('getAddCommodityCount' , {isCount ,foods: this.commodity})
      }
    }
  }
</script>

<style lang="stylus" rel="stylesheet/stylus" scoped>
  @import "../../common/stylus/minxins.styl"
  .cartcontrol
    font-size: 0
    position: absolute;
    right: 10px;
    top: 10px;
    .cart-decrease
      display: inline-block
      padding: 6px
      line-height: 24px
      font-size: 24px
      color: rgb(0, 160, 220)
    .icon-remove_circle_outline
      display: inline-block
      padding 6px
      line-height 24px
      font-size 24px
      color $green
    .cart-count
      display: inline-block
      vertical-align: top
      width: 12px
      padding-top: 6px
      line-height: 24px
      text-align: center
      font-size: 10px
      color: rgb(147, 153, 159)
    .icon-add_circle
      display: inline-block
      padding: 6px
      line-height: 24px
      font-size: 24px
      color $green
      background red
    .count-enter-active,&.count-leave-active
      transition all 1s linear
      opacity 1
    .count-enter,&.count-leave-to
      opacity 0
      transform rotate(180deg)
</style>
